public class Day6 {
    public static void main(String[] args) {
       String s = solve("99","11");
        System.out.println(s);
    }
    public static String solve (String s, String t) {
        // write code here
        if(s.equals("")) {
            return t;
        }else if(t.equals("")) {
            return s;
        }
        int count = Integer.parseInt(t);//循环的次数

        int sl = s.length();
        int len  = sl-1;//字符串最后一个元素的下标
        int[] a1 = new int[sl+2];
        for(int i=0;i<sl;i++) {
            a1[i]=Integer.parseInt(s.charAt(i)+"");
        }

        int[] a = new int[sl*count];
        sl--;
        int k=0;
        while (sl>=0) {
            a[k++]=a1[sl--];
        }
        count--;
        while (count>0) {
            k=0;
            sl=len;
            while (sl>=0) {
                int tmp = a1[sl--]+a[k];
                if(tmp>9) {
                    a[k++]=tmp-10;
                    //a[k]=1;
                    int cur = k;
                    while (1+a[cur]>9) {
                        a[cur]=1+a[cur]-10;
                        cur=cur+1;
                    }
                    a[cur]=1+a[cur];
                }else {
                    a[k++]=tmp;
                }
            }
            count--;
        }
        k=0;
        StringBuilder sb = new StringBuilder();

        while (k<a.length) {
            sb.append(a[k++]);
        }
        sb = sb.reverse();
        k=0;
        while (true) {
            char ch = sb.charAt(k);
            if(ch != '0') {
                break;
            }
            k++;
        }
        return sb.substring(k,a.length);

    }
    public static String solve1 (String s, String t) {
        // write code here
        if(s.equals("")) {
            return t;
        }else if(t.equals("")) {
            return s;
        }
        int sl = s.length();
        int tl =t.length();
        int[] a1 = new int[sl+2];
        int[] a2 = new int[tl+2];
        for(int i=0;i<sl;i++) {
            a1[i]=Integer.parseInt(s.charAt(i)+"");
        }
        for(int i=0;i<tl;i++) {
            a2[i]=Integer.parseInt(t.charAt(i)+"");
        }
        int[] a3 = new int[sl+tl];
        sl--;
        tl--;
        int k=0;
        while(sl>=0&&tl>=0) {
            if(k==0) {
                int tmp = a1[sl--]+a2[tl--];
                if(tmp>9) {
                    a3[k++]=tmp-10;
                    a3[k]=1;
                }else {
                    a3[k++]=tmp;
                }
            }else {
                int tmp = a1[sl--]+a2[tl--]+a3[k];
                if(tmp>9) {
                    a3[k++]=tmp-10;
                    a3[k]=1;
                }else {
                    a3[k++]=tmp;
                }
            }
        }
        while(sl>=0) {
            int tmp = a1[sl--]+a3[k];
            if(tmp>9) {
                a3[k++]=tmp-10;
                a3[k]=1;
            }else {
                a3[k++]=tmp;
            }
        }
        while(tl>=0) {
            int tmp = a2[tl--]+a3[k];
            if(tmp>9) {
                a3[k++]=tmp-10;
                a3[k]=1;
            }else {
                a3[k++]=tmp;
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<k;i++) {
            sb.append(a3[i]);
        }
        if(a3[k]!=0) {
            sb.append(a3[k]);
        }
        return sb.reverse().toString();
    }
}
